﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;


namespace University.Models
{
    public class Mark
    {
        public int MarkId { get; set; }
        [Required(ErrorMessage = "Please provide Grade")]
        [Display(Name = "Grade Value")]
        public int MarkValue { get; set; }

        [Required(ErrorMessage = "Please provide grade type")]
        [Display(Name = "Grade Type")]
        public string Type { get; set; }

       // [Required(ErrorMessage = "Please provide Subject")]
       // [Display(Name = "Subject")]
        public virtual Subject Subject { get; set; }
        public virtual User User { get; set; }
        public virtual Professor Professor { get; set; }

        public string ProfessorId { get; set; }

        public IEnumerable<SelectListItem> Professors
        {
            get
            {
                
                return Proffessors
                    .Select(x => new SelectListItem
                    {
                        Value = x.ProfessorId.ToString(),
                        Text = String.Concat(x.FirstName, " ", x.LastName)
                    });
            }
        }

        public IEnumerable<Professor> Proffessors
        {
            get
            {
                IProfessorRepository professorsRepo = new ProfessorRepository();
                return professorsRepo.All;
            }
        }

        
    }
}